package com.kws.common.security.config;

import com.kws.common.security.interceptor.HeaderInterceptor;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * <b>WebMvcConfig</b>
 *
 * @description: WebMvcConfig <br>
 * @date: 2024/10/28 17:29 <br>
 * @author: lhm <br>
 * @version: 1.0 <br>
 */
public class WebMvcConfig implements WebMvcConfigurer {

    /** 不需要拦截地址 */
    public static final String[] excludeUrls = { "/login", "/logout", "/refresh" };

    @Override
    public void addInterceptors(InterceptorRegistry registry)
    {
        registry.addInterceptor(getHeaderInterceptor())
                .addPathPatterns("/**")
                .excludePathPatterns(excludeUrls)
                .order(-10);
    }

    /**
     * 自定义请求头拦截器
     */
   public HeaderInterceptor getHeaderInterceptor(){
       return new HeaderInterceptor();
   }

}
